location.href="https://www.pulu.com/weixin/home.html";
var id;
if(!$.cookie("MYID")){
    if(/\?id=[0-9a-zA-Z]+/.test(location.href)){
        id=(location.href).match(/id=[0-9a-zA-Z]+/)[0].split("=")[1];
        $.cookie("MYID",id);
    }else{
        location.href="weixin/login.html"
    }
}

//调整PC端布局
if(window.screen.availWidth>540){
    $("#cancelbtn").css("right",(window.screen.availWidth-540)/2+15+"px");
}
$('#commentinput').bind('input propertychange', function(a) {
    if(document.getElementById("commentinput").value){
        if(!/^\s+$/.test(document.getElementById("commentinput").value)){
            $("#sendcommentbtn").attr("class","cmnt_smt");
        }else{
            $("#sendcommentbtn").attr("class","cmnt_smt none_cmnt");
        }
    }else{
        $("#sendcommentbtn").attr("class","cmnt_smt none_cmnt");
    }
});
var clinum;//记录点击的第几个按钮控件，防止重复出现
//监听textarea 状态
function changetext(a){
    var thisshareid= a.id.match(/\d+/)[0];
    if($(a).val()&&$(a).val().length>0&&!/^\s+$/.test($(a).val())){
        //自适应高度
        var wid=a.style.width;
        a.cols=parseInt((wid-10)/15);
        var col=a.cols;
        var val=a.value.length;
        var rownum=1;
        if(val>=col){
            rownum=Math.ceil(val/col);
            if(rownum>=3){
                a.style.overflowY="auto";
                a.rows=3;
            }else{
                a.rows=rownum;
            }
        }
        document.getElementById("sendcommentbtn"+thisshareid).className="";
    }else{
        document.getElementById("sendcommentbtn"+thisshareid).className="cannotclick";
    }
}
//点击展开表情
function showfaceimg(e){
    console.log(e.id);
    var num= e.id.match(/\d+/)[0];
    var searchClass=".faceulplace"+num;
    $(searchClass).toggle(100);
}
//表情插入
function sendface(e){
    console.log(e.parentElement.id);
    var num=e.parentElement.id.match(/\d+/)[0];
    var searchId="#commentinput"+num;
    var word=$(searchId).val();
    word+=" "+e.dataset.key;
    $(searchId).val(word);
    $("#sendcommentbtn"+num).attr("class","");
}
//时间 几天前 几分钟前
function getDateTimeStamp(dateStr){
    dateStr=dateStr.replace(/T/g,' ');
    dateStr=dateStr.replace(/\.[0-9]+/g,'');
    return Date.parse(dateStr.replace(/-/gi,"/"));
}
function getDateDiff(dateTimeStamp){
    var minute = 1000 * 60;
    var hour = minute * 60;
    var day = hour * 24;
    var halfamonth = day * 15;
    var month = day * 30;
    var now = new Date().getTime();
    var diffValue = now - dateTimeStamp;
    if(diffValue < 0){return;}
    var monthC =diffValue/month;
    var weekC =diffValue/(7*day);
    var dayC =diffValue/day;
    var hourC =diffValue/hour;
    var minC =diffValue/minute;
    if(monthC>=1){
        result="" + parseInt(monthC) + "月前";
    }
    else if(weekC>=1){
        result="" + parseInt(weekC) + "周前";
    }
    else if(dayC>=1){
        result=""+ parseInt(dayC) +"天前";
    }
    else if(hourC>=1){
        result=""+ parseInt(hourC) +"小时前";
    }
    else if(minC>=1){
        result=""+ parseInt(minC) +"分钟前";
    }else
        result="刚刚";
    return result;
}
var isclicked="no";
//自己的假数据添加回复自己的方法-------------------------------------------------------
function addothercomjia(e){
    document.getElementsByClassName("callback")[0].style.display="block";
    //reid,uid,nickname,liplace
    var reid= e.dataset.id.match(/[0-9]+/)[0];
    var uid=e.dataset.place;
    var nickname= e.dataset.nick;
    var liplace=e.dataset.place;
    $("#commentinput").attr("placeholder","回复 "+nickname+":");
    document.getElementById("cancelbtn").onclick=function(){
        document.getElementsByClassName("callback")[0].style.display="none";
        document.getElementById("commentinput").value="";
        reid="";
        liplace="";
        $(".swiper-container").css("display","none");
    };
    document.getElementById("sendcommentbtn").onclick=function(){
        if(document.getElementById("commentinput").value&&!document.getElementById("commentinput").value.match(/^\s+$/g)&&isclicked==="no"){
            isclicked="yes";
            var imgs=[];
            var answer={};
            answer.questionId=reid;
            answer.answerUserId=id;
            answer.replyto=uid;
            answer.replytoNick=nickname;
            answer.atype=1;  //评论新闻为1
            answer.up=0;
            answer.down=0;
            answer.content=document.getElementById("commentinput").value;
            var contentcode=answer.content;//保存回复文字 用于插入表情
            var newcontentcode=codetoface(contentcode);//回复文字中插入表情图片
            $.ajax({
                type:"post",
                datatype:"json",
                url:replyurl,
                data:{"puluanswer":answer,"imgs":imgs},
                success:function(data){
                    //location.reload();//重新加载
                    isclicked="no";
                    $("#ul"+liplace).append("<li class='listcom' data-place="+liplace+" data-id='c"+data.Data+"' data-nick='"+nickname+"'><span class='commenter'>"+nickname+" 回复 "+nickname+"</span><span>：</span><span >"+newcontentcode+"</span></li>")
                    console.log(data);
                    document.getElementsByClassName("callback")[0].style.display="none";
                    $(".swiper-container").css("display","none");
                }
            });
        }else{
            console.log("没有输入内容");
        }
    };
}

var currentIndex=1;
//跳转 历史定位
function gohrefftn(e){
    scrollover=0;
    //console.log("保存的地址："+e.dataset.href);
    if(e.dataset.id){
        var neid=e.dataset.id;
        $.ajax({
            type:"post",
            datatype:"json",
            url:addcounturl,
            data:{"newsId":neid},
            success:function(d){
                $.cookie("readyourcurrentIndex",currentIndex);
                var scrollTop=$(".wrapper.home_feed").scrollTop();
                $.cookie("readyourscrollTop",scrollTop);
                location.href=e.dataset.href;
            }
        })
    }else{
        $.cookie("readyourcurrentIndex",currentIndex);
        var scrollTop=$(".wrapper.home_feed").scrollTop();
        $.cookie("readyourscrollTop",scrollTop);
        location.href=e.dataset.href;
    }
}
//删除转发的新闻
var shareid="";
function delmynewsftn(e){
    shareid= e.dataset.shareid;
    $("#delmynews").css("display","block");
}
$("#delmynewsok").click(function(){
    $("#mainp"+shareid).remove();
    $.ajax({
        type:"post",
        data:{"shareId":shareid},
        url:delmynewsurl,
        success:function(d){
            console.log(d);
            $("#delmynews").css("display","none");
        }
    })
});
$("#delmynewscancel").click(function(){
    shareid="";
    $("#delmynews").css("display","none");
});


var id;
if($.cookie("MYID")){id=$.cookie("MYID")};
var returnurl=encodeURIComponent("http://www.pulu.com/weixin/home.html"); //同意后跳转页面
//$(document).ready(function(){
//一级列表

    var headphotobtn=document.getElementsByClassName("photo");
    for(var i2=0;i2<headphotobtn.length;i2++){
        headphotobtn[i2].index=i2;
        headphotobtn[i2].onclick=function(){
            location.href="otherpeoplepage.html?otherid="+headphotobtn[this.index].id;
        }
    }
//////////////////////////////////////////////////////////////////////
    var nick="";
    $().ready(function(){
        var clinum="";//记录点击的第几个按钮控件，防止重复出现
        $.ajax({
            type:"post",
            url:userurl,
            data:{"userId":id},
            success:function(d){
                nick= d.Data.nick;
            }
        });
        if($.cookie("readyourcurrentIndex")){
            //===================有问题============================
            currentIndex=$.cookie("readyourcurrentIndex");
            var allnum=parseFloat($.cookie("readyourcurrentIndex")*6);
            ajget(1,allnum);
        }else{
            ajget(currentIndex,6);
        }
    });
    var scrollover=1;//页面滚动是否结束 1结束了
    var upanddown=127;
    $(window).scroll(function(){
        var mainheight=$("#page_wrapper").height();
        var windowheight=$(window).height();
        var what=$("#page_wrapper").offset().top;
        var chajuli=$("#page_wrapper").offset().top - $(window).scrollTop();
        var cz=windowheight-mainheight+100;
        if(chajuli<cz&&scrollover===1){
            scrollover=0;
            currentIndex++;
            $.cookie("readyourcurrentIndex","");
            $.cookie("readyourscrollTop","");
            ajget(currentIndex,6);
        }
        //导航条隐藏显示
        console.log(chajuli);
        var a2=chajuli;
        if(a2<upanddown){
            //console.log("向下滚动");
            upanddown=a2;
            //向下滚动
            if(chajuli<36){
                $(".fixed_header").css({"position":"fixed","top":"-88px"});
                $(".wrapper.home_feed").css({"margin-top":"44px"});
                $("#page_wrapper").css("margin-top","44px");
            }
        }
        else{
            //console.log("向上滚动");
            upanddown=a2;
            //向上滚动
            if(0<chajuli){
                $(".fixed_header").css({"position":"absolute","top":"0px"});
                $(".wrapper.home_feed").css({"margin-top":"0"});
                $("#page_wrapper").css("margin-top","127px");
            }
        }
    });

    function ajget(currentIndex,pageSize){
        $.ajax({
            type:"get",
            datatype:"json",
            url:readyoursurl+id+"&pageSize="+pageSize+"&currentIndex="+currentIndex,
            success:function(data){
                //console.log(data);
                var alldata=data;
                var fortim=0;//记录for循环次数 是否循环结束
                if(data.Data&&data.Data.length>0){
                    if(data.Data.length<pageSize){
                        $("#waiting").remove();
                        $("#nonews").css("display","block");
                    }
                    for(var i1=0;i1<data.Data.length;i1++){
                        fortim++;
                        var me=i1;//保存对应位置
                        //新闻有图片
                        var imgword="";
                        if(data.Data[i1].thumb){    //href='"+data.Data[i1].url+"'
                            imgword="<div class='feed_answer_preview answer_content'><a onclick='gohrefftn(this)' data-href='"+data.Data[i1].url+"' data-id='"+data.Data[i1].id+"'><div class='truncated_thumbnail_holder'><span class='rendered_qtext'><div class='qtext_image_wrapper'><canvas class='qtext_image_placeholder landscape qtext_image zoomable_in_feed' width='500' height='331' style='visibility: hidden;'></canvas><img class='landscape qtext_image zoomable_in_feed lazy_loaded lazy_loading' src='"+data.Data[i1].thumb+"'></div></span></div></a></div>";
                        }
                        //用户有头像
                        var uimgword="";
                        if(data.Data[i1].userAva){
                            uimgword="<img onclick='gohrefftn(this)' data-href='otherpeoplepage.html?otherid="+data.Data[i1].userId+"' class='profile_photo_img' src='http://42.62.66.198:8003/"+data.Data[i1].userAva+"'>";
                        }else{
                            uimgword="<img onclick='gohrefftn(this)' data-href='otherpeoplepage.html?otherid="+data.Data[i1].userId+"' class='profile_photo_img' src='../img/af8.png'>";
                        }
                        // 用户有昵称
                        var unick="";
                        if(data.Data[i1].nick&&data.Data[i1].nick.length>0){
                            unick=data.Data[i1].nick;
                        }
                        //行业兴趣
                        var hobjob="";
                        //用户转发新闻有自己的评论
                        var uview="";
                        if(data.Data[i1].des){
                            var newcontentcode=codetoface(data.Data[i1].des);//文字中插入表情图片
                            uview="<div class='info_wrapper senderview'><div class='info'><span class='feed_item_answer_user'>"+newcontentcode+"</span></div></div>"
                        }
                        //时间
                        var datatime="";
                        if(data.Data[i1].shareTime){
                            datatime=getDateDiff(getDateTimeStamp(data.Data[i1].shareTime));
                        }
                        //是否为自己的新闻
                        var mynews="";
                        if(data.Data[i1].userId==id){
                            mynews="<div class='delnews' onclick='delmynewsftn(this)' data-shareid='"+data.Data[i1].shareId+"'>删除</div>";
                        }
                        //新闻是否有评论
                        var ncom="";
                        var bignum=[];//数组保存代码段
                        var pljson;//每条评论是否有回复
                        if(data.Data[i1].puluNewsAnswerExt&&data.Data[i1].puluNewsAnswerExt.length>0){
                            var tim=0;
                            for(var r1=0;r1<data.Data[i1].puluNewsAnswerExt.length;r1++){
                                tim++;
                                ////获取有评论新闻的评论序号 对应ul的位置
                                data.Data[i1].puluNewsAnswerExt[r1].index=r1;
                                ////回复有评论
                                var replyname="";
                                if(data.Data[i1].puluNewsAnswerExt[r1].toUserName){
                                    replyname=" 回复 "+data.Data[i1].puluNewsAnswerExt[r1].toUserName;
                                }
                                var newcontentcode=codetoface(data.Data[i1].puluNewsAnswerExt[r1].answerContent);//文字中插入表情图片
                                ncom+="<li class='listcom' data-place='"+data.Data[i1].shareId+"' data-id='c"+data.Data[i1].puluNewsAnswerExt[r1].questionId+"' data-nick='"+data.Data[i1].puluNewsAnswerExt[r1].userName+"'><span class='commenter' id='"+data.Data[i1].puluNewsAnswerExt[r1].answerUserId+"'>"+data.Data[i1].puluNewsAnswerExt[r1].userName+replyname+"</span><span>：</span><span >"+newcontentcode+"</span></li>";
                                if(tim===data.Data[i1].puluNewsAnswerExt.length){

                                    var tuijian="";
                                    if(data.Data[i1].isStranger===1){
                                        tuijian="<div class='tuijian'></div>";
                                    }
                                    var typeneme=data.Data[i1].newsTypeName;
                                    ncom="<ul class='commentplace' id='ul"+data.Data[i1].shareId+"'><li class='toparrow'></li> "+ncom+"</ul>";
                                    $(".HomeMainFeed").append("<div class='pagedlist_item' id='mainp"+data.Data[i1].shareId+"'> <div class='feed_item feed_type_answer'>"+tuijian+"<div class='ContentHeader'> <div class='photo_info_layout size_small'> <div class='photo_wrapper'> <div class='photo'> "+ uimgword+" </div> </div> <div class='info_wrapper'> <span class='feed_item_answer_user'> <span class='user'>"+unick+"</span><span class='sign'></span> </span> <div class='ContentFooter'>"+datatime+"</div> </div> </div> </div> "+uview+"<h2 class='no_highlight'><a class='question_link hrefto' onclick='gohrefftn(this)' data-id='"+data.Data[i1].id+"' data-href='"+data.Data[i1].url+"'><span class='question_text'><span class='rendered_qtext'>( "+typeneme+" )"+data.Data[i1].title+"</span></span></a></h2><div class='Answer'><div class='QuestionAnswerVerbose SimpleToggle Toggle' id='main"+data.Data[i1].shareId+"'>"+imgword+"<div class='ActionBar'><div class='action_bar_inner'><div class='action_item'><a class='ReadMoreActionItem eyesbox'><span class='answer_count' >"+data.Data[i1].count+"</span></a></div>"+mynews+"<div class='overflow action_item overflow_link'><a class='overflow_link'><span class='dots overflow_dots'></span></a></div><div class='actionlist'><div class='collectbtn' id='coll"+data.Data[i1].id+"'>收藏</div><div id='newsid"+data.Data[i1].id+"' data-shareid='"+data.Data[i1].shareId+"' class='addnewscom'>评论</div></div></div></div>"+ncom+"</div></div></div></div>");
                                }
                            }
                        }else{//没有评论直接加载新闻
                            var tuijian="";
                            if(data.Data[i1].isStranger===1){
                                tuijian="<div class='tuijian'></div>";
                            }
                            var typeneme=data.Data[i1].newsTypeName;
                            $(".HomeMainFeed").append("<div class='pagedlist_item' id='mainp"+data.Data[i1].shareId+"'> <div class='feed_item feed_type_answer'>"+tuijian+"<div class='ContentHeader'> <div class='photo_info_layout size_small'> <div class='photo_wrapper'> <div class='photo'> "+ uimgword+" </div> </div> <div class='info_wrapper'> <span class='feed_item_answer_user'> <span class='user'>"+unick+"</span><span class='sign'></span> </span> <div class='ContentFooter'>"+datatime+"</div> </div> </div> </div> "+uview+"<h2 class='no_highlight'><a class='question_link hrefto' onclick='gohrefftn(this)' data-id='"+data.Data[i1].id+"' data-href='"+data.Data[i1].url+"'><span class='question_text'><span class='rendered_qtext'>( "+typeneme+" )"+data.Data[i1].title+"</span></span></a></h2><div class='Answer'><div class='QuestionAnswerVerbose SimpleToggle Toggle' id='main"+data.Data[i1].shareId+"'>"+imgword+"<div class='ActionBar'><div class='action_bar_inner'><div class='action_item'><a class='ReadMoreActionItem eyesbox'><span class='answer_count' >"+data.Data[i1].count+"</span></a></div>"+mynews+"<div class='overflow action_item overflow_link'><a class='overflow_link'><span class='dots overflow_dots'></span></a></div><div class='actionlist'><div class='collectbtn' id='coll"+data.Data[i1].id+"'>收藏</div><div id='newsid"+data.Data[i1].id+"'  data-shareid='"+data.Data[i1].shareId+"' class='addnewscom'>评论</div></div></div></div></div></div></div></div>");
                        }
                        //定位滚动跳转
                        if(fortim===data.Data.length&& $.cookie("readyourscrollTop")){
                            var t=parseFloat($.cookie("readyourscrollTop"));
                            $(".wrapper.home_feed").scrollTop(t);
                        }
                        //展示网站公司信息
                        $("#footer").css("display","block");
                        var addnewscom=document.getElementsByClassName("addnewscom");   //评论按钮
                        for(var r2=0;r2<addnewscom.length;r2++){
                            var anid="";
                            var shareId="";
                            addnewscom[r2].index=r2;
                            addnewscom[r2].onclick=function(){
                                anid=(addnewscom[this.index].id).match(/[0-9]+/)[0];
                                shareId=parseFloat(addnewscom[this.index].dataset.shareid);
                                $("#commentinput").attr("placeholder","");
                                document.getElementsByClassName("callback")[0].style.display="block";
                                $("#commentinput").focus();
                                sendcom(anid,shareId);
                            }
                        }
                        var listcom=document.getElementsByClassName("listcom");    //每一条评论
                        for(var r3=0;r3<listcom.length;r3++){
                            var reid="";
                            var nickname="";
                            var liplace="";
                            listcom[r3].index=r3;
                            listcom[r3].onclick=function(){
                                reid=(listcom[this.index].dataset.id).match(/[0-9]+/)[0];
                                nickname=listcom[this.index].dataset.nick;
                                liplace=listcom[this.index].dataset.place;  //用于添加评论假数据查找li所在的ul的位置
                                var uid=listcom[this.index].childNodes.item(0).id;
                                document.getElementsByClassName("callback")[0].style.display="block";
                                $("#commentinput").focus();
                                addothercom(reid,uid,nickname,liplace);
                            }
                        }
                        var collectbtn=document.getElementsByClassName("collectbtn"); //收藏
                        for(var r4=0;r4<collectbtn.length;r4++){
                            var collectid="";
                            collectbtn[r4].index=r4;
                            collectbtn[r4].onclick=function(){
                                collectid=(collectbtn[this.index].id).match(/[0-9]+/)[0];
                                $.ajax({
                                    type:"post",
                                    datatype:"json",
                                    url:"http://42.62.66.198:9001/api/PuluCollection/Addpulu_collection",
                                    data:{"contentid":collectid,"userid":id,"contenttype":1},
                                    success:function(data){
                                        //console.log(data);
                                        document.getElementById("collectword").style.display="block";
                                        function disnone(){
                                            document.getElementById("collectword").style.display="none";
                                        }
                                        setTimeout(disnone,1000);
                                        clearTimeout();
                                    }
                                })
                            }
                        }
                        //分享新闻 提问 模态框
                        var overflowlist=document.getElementsByClassName("overflow");
                        var actionlist=document.getElementsByClassName("actionlist");
                        for(var i3=0;i3<overflowlist.length;i3++){
                            overflowlist[i3].index=i3;
                            overflowlist[i3].onclick=function(){
                                if(clinum){console.log(clinum)}
                                //========================================
                                if(clinum&&clinum.toString()==this.index.toString()){ //当前按钮已经点击
                                    //console.log(clinum);
                                    actionlist[this.index].className="actionlist displaied2";
                                    clinum="";
                                }else if(clinum&&clinum.toString()!=this.index.toString()){//其他按钮已经点击了
                                    actionlist[clinum].className="actionlist displaied2";//关闭其他按钮
                                    actionlist[this.index].className="actionlist displaied1";//展开当前按钮
                                    clinum=this.index.toString();//更改当前记录数字
                                }else{//第一次点击
                                    //console.log("第一次点击的位置",this.index);
                                    actionlist[this.index].className="actionlist displaied1";//展开当前按钮
                                    clinum=this.index.toString();//更改当前记录数字 wz位置
                                }
                                //========================================
                            }
                        };
                        //点击屏幕实现弹框隐藏 &&与||
                        var bigbody=document.getElementById("page_wrapper");
                        bigbody.onclick=function(e){
                            for(var i=0;i<actionlist.length;i++){
                                if(actionlist[i].className=="actionlist displaied1"){
                                    if(e.target.className!=="overflow_link"&&e.target.className!=="dots overflow_dots"&&e.target.className!=="callback"){
                                        actionlist[i].className="actionlist displaied2";
                                        clinum="";
                                    }
                                }
                            }
                        };
                        scrollover=1;//滚动结束了
                    }
                }else{
                    scrollover=0;
                    $("#waiting").remove();
                    $("#nonews").css("display","block");
                }
            }
        });
    }
//添加评论按钮
    function sendcom(anid,shareId){
        //取消按钮点击
        document.getElementById("cancelbtn").onclick=function(){
            document.getElementsByClassName("callback")[0].style.display="none";
            document.getElementById("commentinput").value="";
            anid="";
            shareId="";
            $(".swiper-container").css("display","none");
            $("#commentinput").attr("placeholder","回复:");
            //$("#commentinput").attr("rows","1");
            //$(".wrapper.home_feed").css("bottom",0);
            $("#sendcommentbtn").attr("class","cmnt_smt none_cmnt");
        };
        //确定按钮点击
        document.getElementById("sendcommentbtn").onclick=function(){
            if(document.getElementById("commentinput").value&&!document.getElementById("commentinput").value.match(/^\s+$/g)&&isclicked==="no"){
                isclicked="yes";
                var imgs=[];
                var answer={};
                answer.questionId=anid;
                answer.answerUserId=id;
                answer.atype=1;  //评论新闻为1
                answer.isShare=1;
                answer.shareId=shareId;
                answer.up=0;
                answer.down=0;
                answer.content=document.getElementById("commentinput").value;
                var contentcode=answer.content;//保存回复文字 用于插入表情
                $.ajax({
                    type:"post",
                    datatype:"json",
                    url:replyurl,
                    data:{"puluanswer":answer,"imgs":imgs},
                    success:function(data){
                        var newcontentcode=codetoface(contentcode);//回复文字中插入表情图片
                        isclicked="no";
                        document.getElementById("commentinput").value="";
                        //$(".wrapper.home_feed").css("bottom","0");
                        //$("#commentinput").attr("rows","1");
                        // 重新加载=========================================
                        if($("#ul"+shareId+" li")&&$("#ul"+shareId+" li").length>0){
                            $("#ul"+shareId).append("<li class='listcom' data-place="+shareId+" data-id='c"+data.Data+"' data-nick='"+nick+"' onclick='addothercomjia(this)'><span class='commenter'>"+nick+"</span><span>：</span><span >"+newcontentcode+"</span></li>")
                        }else{
                            $("#main"+shareId).append("<ul class='commentplace' id='ul"+shareId+"'><li class='toparrow'></li><li class='listcom'  data-place="+shareId+" data-id='c"+data.Data+"' data-nick='"+nick+"' onclick='addothercomjia(this)'><span class='commenter'>"+nick+"</span><span>：</span><span >"+newcontentcode+"</span></li></ul>")
                        }
                        document.getElementsByClassName("callback")[0].style.display="none";
                        $("#commentinput").attr("placeholder","回复:");
                        //$(".wrapper.home_feed").css("bottom",0);
                        $("#sendcommentbtn").attr("class","cmnt_smt none_cmnt");
                        $(".swiper-container").css("display","none");
                    }
                });
            }else{
                console.log("没有输入内容");
            }
        };
    }
//回复他人评论
    function addothercom(reid,uid,nickname,liplace){
        //console.log(nickname);
        $("#commentinput").attr("placeholder","回复 "+nickname+":");
        document.getElementById("cancelbtn").onclick=function(){
            document.getElementsByClassName("callback")[0].style.display="none";
            document.getElementById("commentinput").value="";
            reid="";
            liplace="";
            $(".swiper-container").css("display","none");
            console.log("点击了取消3");
            //$(".wrapper.home_feed").css("bottom",0);
            $("#sendcommentbtn").attr("class","cmnt_smt none_cmnt");
            $(".swiper-container").css("display","none");
        };
        document.getElementById("sendcommentbtn").onclick=function(){
            if(document.getElementById("commentinput").value&&!document.getElementById("commentinput").value.match(/^\s+$/g)&&isclicked==="no"){
                isclicked="yes";
                var imgs=[];
                var answer={};
                answer.questionId=reid;
                answer.answerUserId=id;
                answer.replyto=uid;
                answer.replytoNick=nickname;
                answer.atype=1;  //评论新闻为1
                answer.shareId=liplace;
                answer.isShare=1;
                answer.up=0;
                answer.down=0;
                answer.content=document.getElementById("commentinput").value;
                var contentcode=answer.content;//保存回复文字 用于插入表情
                $.ajax({
                    type:"post",
                    datatype:"json",
                    url:replyurl,
                    data:{"puluanswer":answer,"imgs":imgs},
                    success:function(data){
                        var newcontentcode=codetoface(contentcode);//回复文字中插入表情图片
                        isclicked="no";
                        document.getElementById("commentinput").value="";
                        $("#ul"+liplace).append("<li class='listcom' data-place="+liplace+" data-id='c"+data.Data+"' data-nick='"+nick+"' onclick='addothercomjia(this)'><span class='commenter'>"+nick+" 回复 "+nickname+"</span><span>：</span><span>"+newcontentcode+"</span></li>");
                        document.getElementsByClassName("callback")[0].style.display="none";
                        $("#commentinput").attr("placeholder","回复:");
                        //$(".wrapper.home_feed").css("bottom",0);
                        $("#sendcommentbtn").attr("class","cmnt_smt none_cmnt");
                        $(".swiper-container").css("display","none");
                    }
                });
            }else{
                console.log("没有输入内容");
            }
        };
    }
//})